{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from urllib import request"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '上海',\n",
       " '海南',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '福建',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '海南',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '浙江',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '广东',\n",
       " '上海',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '海南',\n",
       " '福建',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '福建',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '浙江',\n",
       " '',\n",
       " '山东',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '海南',\n",
       " '',\n",
       " '',\n",
       " '安徽',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '海南',\n",
       " '',\n",
       " '',\n",
       " '福建',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '浙江',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '河北',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '陕西',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '山东',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '四川',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '北京',\n",
       " '',\n",
       " '',\n",
       " '上海',\n",
       " '',\n",
       " '广东',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '湖北',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '',\n",
       " '']"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "list_pub_location=[]   # 视频上传地\n",
    "\n",
    "for j in range(145, 151):\n",
    "    headers = {\n",
    "        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42'\n",
    "        }\n",
    "    url = f'https://api.bilibili.com/x/web-interface/popular/series/one?number={j}'\n",
    "\n",
    "    response = requests.get(url, headers = headers)\n",
    "    all_data = response.json()\n",
    "\n",
    "    for i in range(len(all_data['data']['list'])):\n",
    "        if 'pub_location' in all_data['data']['list'][i] is not None:\n",
    "            list_pub_location.append(all_data['data']['list'][i]['pub_location'])\n",
    "        else:\n",
    "            list_pub_location.append('')\n",
    "\n",
    "display(list_pub_location)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
